#!/bin/bash
echo "=== 构建通用子模块管理工具 ==="

mkdir -p build
cd build

# 尝试使用CMake
if command -v cmake &> /dev/null; then
    echo "使用CMake构建..."
    cmake ..
    make -j4
else
    echo "使用直接编译..."
    cd ..
    g++ -std=c++17 -I include -o usm src/main.cpp
fi

if [ -f "usm" ] || [ -f "build/usm" ]; then
    echo "✅ 构建成功!"
    echo "运行: ./usm help"
else
    echo "❌ 构建失败"
    exit 1
fi
